package com.community.body.service.impl;

import java.util.List;

import com.community.body.domain.ZyOwner;
import com.community.body.dto.OwnerDTO;
import com.community.body.mapper.ZyOwnerMapper;
import com.community.body.service.IZyOwnerService;
import com.community.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 业主 Service业务层处理
 * 
 * @author community
 * @date 2024-04-11
 */
@Service
public class ZyOwnerServiceImpl implements IZyOwnerService
{
    @Resource
    private ZyOwnerMapper zyOwnerMapper;

    /**
     * 查询业主 
     * 
     * @param ownerId 业主 主键
     * @return 业主 
     */
    @Override
    public ZyOwner selectZyOwnerByOwnerId(Long ownerId)
    {
        return zyOwnerMapper.selectZyOwnerByOwnerId(ownerId);
    }

    /**
     * 查询业主 列表
     * 
     * @param ownerDTO 业主
     * @return 业主 
     */
    @Override
    public List<OwnerDTO> selectZyOwnerList(OwnerDTO ownerDTO)
    {
        if("admin".equals(ownerDTO.getUserName()) && ownerDTO.getUserName() != null){
            ownerDTO.setDeptId(0);
        }
        return zyOwnerMapper.selectZyOwnerList(ownerDTO);
    }

    /**
     * 新增业主 
     * 
     * @param zyOwner 业主 
     * @return 结果
     */
    @Override
    public int insertZyOwner(ZyOwner zyOwner)
    {
        zyOwner.setCreateTime(DateUtils.getNowDate());
        return zyOwnerMapper.insertZyOwner(zyOwner);
    }

    /**
     * 修改业主 
     * 
     * @param zyOwner 业主 
     * @return 结果
     */
    @Override
    public int updateZyOwner(ZyOwner zyOwner)
    {
        zyOwner.setUpdateTime(DateUtils.getNowDate());
        return zyOwnerMapper.updateZyOwner(zyOwner);
    }

    /**
     * 批量删除业主 
     * 
     * @param ownerIds 需要删除的业主 主键
     * @return 结果
     */
    @Override
    public int deleteZyOwnerByOwnerIds(Long[] ownerIds)
    {
        return zyOwnerMapper.deleteZyOwnerByOwnerIds(ownerIds);
    }

    /**
     * 删除业主 信息
     * 
     * @param ownerId 业主 主键
     * @return 结果
     */
    @Override
    public int deleteZyOwnerByOwnerId(Long ownerId)
    {
        return zyOwnerMapper.deleteZyOwnerByOwnerId(ownerId);
    }

    @Override
    public List<OwnerDTO> selectZyOwnerQuery(Long[] longArray) {
        return zyOwnerMapper.selectZyOwnerQuery(longArray);
    }
}
